package org.vuzya.motivateme.models;

import android.content.ContentValues;
import android.database.Cursor;
import android.provider.BaseColumns;

public class QuestionAnswers implements BaseColumns {
	public static final String TABLE_NAME = "QuestionAnswers";
	public static final String QUESTION_NUMBER = "QuestionNumber";
	public static final String ANSWER = "Answer";
	public static final String MOTIVATION_ID = "MotivationID";
	public static final String[] SELECTION = { _ID, QUESTION_NUMBER, ANSWER, MOTIVATION_ID };
	
	private long id = -1;
	private int questionNumber;
	private String answer;
	private long motivationId;
	
	public QuestionAnswers(long motivationId){
		this.motivationId=motivationId;
	}
	
	public QuestionAnswers(Cursor cursor){		
		id = cursor.getLong(cursor.getColumnIndex(_ID));
		questionNumber = cursor.getInt(cursor.getColumnIndex(QUESTION_NUMBER));
		answer = cursor.getString(cursor.getColumnIndex(ANSWER));
		id = cursor.getLong(cursor.getColumnIndex(MOTIVATION_ID));
	}

	public ContentValues extractValues(){
		ContentValues cv = new ContentValues();
		if(id!=-1){
			cv.put(_ID, id);
		}
		cv.put(QUESTION_NUMBER, questionNumber);
		cv.put(ANSWER, answer);
		cv.put(MOTIVATION_ID, motivationId);
		return cv;
	}
	
	public int getQuestionNumber() {
		return questionNumber;
	}
	public void setQuestionNumber(int questionNumber) {
		this.questionNumber = questionNumber;
	}
	public String getAnswer() {
		return answer;
	}
	public void setAnswer(String answer) {
		this.answer = answer;
	}
	public long getMotivationId() {
		return motivationId;
	}
	public void setMotivationId(long motivationId) {
		this.motivationId = motivationId;
	}
	public long getId() {
		return id;
	}
}
